/* nixonFTP
 * FTP client version 0.1
 * Copyright (C) 2010 NIXON Development Corporation.
 * All rights reserved.
 * http://members.shaw.ca/nixon.com
*/

package nixonftp.ui;

import nixonftp.*;
import java.util.HashMap;
import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;

/**
 *
 * @author Billy
 */
public class NXMenu extends JPopupMenu {
	private HashMap menuItems = new HashMap();
	private HashMap separators = new HashMap();

	public void addToIndex(String id, Object o) {
		menuItems.put(id, o);
	}

	public NXMenuItem addImpl(String title, String id, ImageIcon icon) {
		String strTransfer;
		NXMenuItem menuItem = new NXMenuItem(title, id);
		if (icon != null) {
			menuItem.setIcon(icon);
		}
		menuItems.put(id, menuItem);
		add(menuItem);
		return menuItem;
	}

	public void addMenu(JMenu menu, ImageIcon icon) {
		NXMenuItem item;
		for (int x = 0; x < menu.getItemCount(); x++) {
			item = (NXMenuItem) menu.getItem(x);
			menuItems.put(item.id, item);
		}
		menu.setIcon(icon);
		add(menu);
	}

	public void addSeparator(String name) {
		JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
		separators.put(name, separator);
		add(separator);
	}

	public HashMap getIndex() {
		return menuItems;
	}

	public HashMap getSeparators() {
		return separators;
	}
}



